<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="js/jquery3.2.js" ></script>
		<script>
			var flaguname=false;
			var flagupwd=false;
			$(function (){
				$("#username").focus(function(){
					var namepoint=$("#namepoint");
					namepoint.html("用户名必须是手机号或者字母数字下划线长度为5-10");
					namepoint.css("color","red");
				});
				$("#username").blur(function (){
					var username=$(this).val();
					var namepoint=$("#namepoint");
					if(username.length==11)
					{
						var regStr2=/[0-9]{11}/;
						var reg2=new RegExp(regStr2);
						if(reg2.test(username))
						{
							namepoint.html("用户名正确");
							namepoint.css("color","green");
							flaguname=true;
							return;
						}
						namepoint.html("用户名必须是账号或者手机号");
						namepoint.css("color","red");
					}
					else{
						
						var regStr=/[\w]{5,10}/;
						var reg=new RegExp(regStr);
						if(!reg.test(username))
						{
							namepoint.html("用户名长度必须为字母数字下划线，长度为5-10");
							namepoint.css("color","red");
							return;
						}
						var regStr1=/[^0-9]/;
						var reg1=new RegExp(regStr1);
						if(!reg1.test(username.substring(0,1)))
						{
							namepoint.html("首字母不能为数字");
							namepoint.css("color","red");
							return;
						}
						namepoint.html("用户名正确");
						namepoint.css("color","green");
						flaguname=true;
					}
				});
			});
			$(function (){
				$("#userpwd").focus(function (){
					var pwdpoint=$("#pwdpoint");
					pwdpoint.html("密码长度为6到10");
					pwdpoint.css("color","red");
				});
				$("#userpwd").blur(function (){
					var userpwd=$(this).val();
					var pwdpoint=$("#pwdpoint");
					var regStr2=/[0-9]{6,10}/;
					var reg2=new RegExp(regStr2);
					if(reg2.test(userpwd))
					{
						pwdpoint.html("密码格式正确");
						pwdpoint.css("color","green");
						flagupwd=true;
					}
				});
				$("#submit").click(function (){
					
					if(flagupwd==false||flaguname==false)
					{
						return false;
					}
					return true;
				});
				
			});
			
		</script>
		
	</head>
	<body>
		<form action="/user/login" method="post"  >
		用户名： <input id="username" type="text" name="username" id="username"  maxlength="11"/><span id="namepoint"></span><br />
		密码：  <input  id="userpwd" name="userpwd" id="userpwd"  maxlength="10"/><span id="pwdpoint"></span><br />
			<input id="reset" type="reset" value="重置" />
			<input id="submit" type="submit" value="登录" />
		</form>
		
	</body>
</html>
